package com.wjb.xietong.control;

import com.wjb.xietong.server.IRequestResultListener;
import com.wjb.xietong.server.login.LoginParam;
import com.wjb.xietong.server.login.LoginService;
import com.wjb.xietong.server.myTask.MyTaskParam;
import com.wjb.xietong.server.myTask.MyTaskService;
import com.wjb.xietong.server.notify.GetNotifyParam;
import com.wjb.xietong.server.notify.GetNotifyService;
import com.wjb.xietong.server.project.ProjectParam;
import com.wjb.xietong.server.project.ProjectService;
import com.wjb.xietong.server.task.GetTaskParam;
import com.wjb.xietong.server.task.GetTaskService;
import com.wjb.xietong.server.task.UpdateTaskStatuParam;
import com.wjb.xietong.server.task.UpdateTaskStatuService;
import com.wjb.xietong.server.taskReply.TaskFileUploadParam;
import com.wjb.xietong.server.taskReply.TaskFileUploadService;
import com.wjb.xietong.server.taskReply.TaskReplyParam;
import com.wjb.xietong.server.taskReply.TaskReplyService;
import com.wjb.xietong.server.taskReply.TaskFileUploadService.ITaskFileUploadListener;
import com.wjb.xietong.server.taskdetail.GetTaskDetailParam;
import com.wjb.xietong.server.taskdetail.GetTaskDetailService;
import com.wjb.xietong.server.topic.GetCommentListParam;
import com.wjb.xietong.server.topic.GetCommentListService;
import com.wjb.xietong.server.topic.GetZanPeopleListParam;
import com.wjb.xietong.server.topic.GetZanPeopleListService;
import com.wjb.xietong.server.topic.MessageNotifyParam;
import com.wjb.xietong.server.topic.MessageNotifyService;
import com.wjb.xietong.server.topic.ReplyParam;
import com.wjb.xietong.server.topic.ReplyService;
import com.wjb.xietong.server.topic.TopicParam;
import com.wjb.xietong.server.topic.TopicService;

public class WJBControl {
	/**
	 * 请求登录
	 * 
	 * @param uniqueID
	 * @param param
	 * @param listener
	 * @return IDs.REQUEST_OK :Ok otherwise:failed
	 */
	public static int requestLogin(long uniqueID, LoginParam param,
			IRequestResultListener listener) {
		LoginService service = new LoginService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}

	/**
	 * 请求获取任务列表
	 * 
	 * @param uniqueID
	 * @param param
	 * @param listener
	 * @return
	 */
	public static int requestGetTask(long uniqueID, GetTaskParam param,
			IRequestResultListener listener) {
		GetTaskService service = new GetTaskService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}

	/**
	 * 请求获取任务详细列表
	 * 
	 * @param uniqueID
	 * @param param
	 * @param listener
	 * @return
	 */
	public static int requestGetDetailTask(long uniqueID,
			GetTaskDetailParam param, IRequestResultListener listener) {
		GetTaskDetailService service = new GetTaskDetailService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}

	/**
	 * 请求获取项目列表
	 * 
	 * @param uniqueID
	 * @param param
	 * @param listener
	 * @return
	 */
	public static int requestGetProject(long uniqueID, ProjectParam param,
			IRequestResultListener listener) {
		ProjectService service = new ProjectService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}

	/**
	 * 请求获取我的任务列表
	 * 
	 * @param uniqueID
	 * @param param
	 * @param listener
	 * @return
	 */
	public static int requestGetMyTask(long uniqueID, MyTaskParam param,
			IRequestResultListener listener) {
		MyTaskService service = new MyTaskService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}

	/**
	 * 请求获取通知列表
	 * 
	 * @param uniqueID
	 * 
	 * @param param
	 * @param listener
	 * @return
	 */
	public static int requestGetNotify(long uniqueID, GetNotifyParam param,
			IRequestResultListener listener) {
		GetNotifyService service = new GetNotifyService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}

	/**
	 * 更改任务状态
	 * 
	 * @param operationStatus
	 *            ( 0:未完成 1：已完成)
	 */
	public static int updateTaskStatus(long uniqueID,
			UpdateTaskStatuParam param, IRequestResultListener listener) {
		UpdateTaskStatuService service = new UpdateTaskStatuService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}

	/**
	 * 获取工作圈信息列表
	 * 
	 * @see 特别说明： 1 在回复json中的字符串有"content":
	 *      "今日工作内容：!!wjb!!test11111111111##wjb##今日工作心得：
	 *      !!wjb!!test11111111111##wjb##明日工作计划：!!wjb!!test11111111111" ,
	 *      这样的内容，其中!!wjb!!代表一个换行，##wjb##代表两个换行 zanflag 0是没赞过 1是赞过，赞过没赞过颜色会不一样
	 */
	public static int requestGetTopicList(long uniqueID, TopicParam param,
			IRequestResultListener listener) {
		TopicService service = new TopicService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}

	/**
	 * 点赞或回复
	 * 
	 * @see 如果是点赞则不需要填content字段
	 * 		如果是回复则不需要填zanType字段
	 */
	public static int requestReply(long uniqueID, ReplyParam param,
			IRequestResultListener listener) {
		ReplyService service = new ReplyService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}
	
	/**
	 * 动态消息提醒
	 */
	public static int messageNotify(long uniqueID, MessageNotifyParam param, 
			IRequestResultListener listener){
		MessageNotifyService service = new MessageNotifyService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}
	
	/**
	 * 获取已赞联系人列表
	 */
	public static int requestGetZanPeopleList(long uniqueID, GetZanPeopleListParam param, 
			IRequestResultListener listener){
		GetZanPeopleListService service = new GetZanPeopleListService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}
	
	/**
	 * 获取评论列表
	 */
	public static int requestGetCommentList(long uniqueID, GetCommentListParam param, 
			IRequestResultListener listener){
		GetCommentListService service = new GetCommentListService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}
	
	/**
	 * 附件上传
	 */
	public static int requestUploadFile(long uniqueID, TaskFileUploadParam param, 
			ITaskFileUploadListener listener){
		TaskFileUploadService service = new TaskFileUploadService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}
	
	/**
	 * 任务回复
	 */
	public static int requestReplyTask(long uniqueID, TaskReplyParam param, 
			IRequestResultListener listener){
		TaskReplyService service = new TaskReplyService();
		service.setParameter(uniqueID, listener, param);
		return service.request();
	}
}
